package com.yxy.controller.admin;

import com.yxy.common.Result;
import com.yxy.constant.RequestMapperConstant;
import com.yxy.domain.dto.VersionDTO;
import com.yxy.domain.vo.VersionVO;
import com.yxy.service.VersionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(RequestMapperConstant.ADMIN_REQUEST_MAPPER + "version")
@Slf4j
public class VersionController {

    private final VersionService versionService;
    public VersionController(VersionService versionService) {
        this.versionService = versionService;
    }

    /**
     * 发布版本
     * @return
     */
    @PostMapping("/release")
    public Result<String> releaseVersion(@RequestBody VersionDTO versionDTO){
        log.info("发布版本：{}", versionDTO);
        versionService.releaseVersion(versionDTO);
        return Result.success("发布成功");
    }

    /**
     * 获取版本列表
     * @return
     */
    @GetMapping("/list")
    public Result<List<VersionVO>> list(){
        log.info("获取版本列表");
        List<VersionVO> voList = versionService.list();
        return Result.success("", voList);
    }
}
